#!/bin/bash
#判断选项个数
if [[ $# -eq 0 ]];then
  echo "Usage $0 file or dirs"
  exit 1
fi

func Help() {
    echo "Do you want to continue, input enter to next"
    read -p "" aaaaaaaaaa
}

func main() {
    mytemp=$1
    D=/temp/$(date +%Y%m%d%H%M%S_hsz)
    [ ! -d $D ] && mkdir -p $D
    if echo $1 |grep , &> /dev/null;then #输入的惨参数是使用逗号隔开。如：f1,f2,f3等
      mytemp="`echo $mytemp|tr ',' '\n'`"
    fi

    for i in $mytemp
    do
      if ! ls -l $i &> /dev/null;then #判断是否有这个文件
        continue #不存在就终止这次循环
      fi
      if ls -l $i |grep -Ew 'etc| usr |bin' &> /dev/null;then #设置不能删除的目录
        echo "you do not delete [ $i ]"
      fi
      echo "now you want to delete >>> $i <<<" && ls -l $i
      HELP
      /bin/mv "$i" $D
      echo "`date +%F-%T` -- "$i" Moved  to $D" >> /root/mv_data.log
    done
    if [[ `ls -1 $D |wc -l` -eq 0 ]];then #删除空目录
      rm -r $D
    fi
}

main $1